home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk8 / qint / qint.doc < prev    next >
Text File  |  1995-03-18  |  5KB  |  128 lines

  1.  
  2.                QINT DOCUMENTATION
  3.  
  4.         Matthew Dillon
  5.  
  6.         dillon@ucbvax.berkeley.edu    ARPA
  7.         ...!ihnp4!ucbvax!dillon    USENET
  8.  
  9. NOTE!!!!!   Lattice Users must replace the 'jsr _geta4' call with the
  10.         appropriate call to retrieve the address register for the
  11.         small data model before compiling!    You might have to make
  12.         other modifications as well (I don't know since I don't
  13.         have Lattice).
  14.  
  15. The Calls:
  16.     char oldpri;        range -128 to 127
  17.     char newpri;
  18.     char pri;
  19.     long signum;        0 .. 31
  20.  
  21.     void (*vector)();   function vector returning nothing
  22.     void (*oldvec)();
  23.  
  24.     While active Q interrupt vectors exist, the tc_ExceptCode in the
  25.     task structure will be modified.  The old tc_ExceptCode is used if
  26.     an unknown exception occurs (one that is not a Q interrupt).
  27.  
  28.     oldpri = SetQPri(newpri)
  29.  
  30.     Set the task's current Q priority.  Any Q interrupts of lower or
  31.     equal priority that occur will be queued until the priority is
  32.     dropped sufficiently.
  33.  
  34.     The initial task priority is -128 (essentially allowing all Q
  35.     interrupts -127 to 127 to occur).
  36.  
  37.     oldvec = SetQVector(signum, vector, arg, pri)
  38.  
  39.     If vector is non-null, enables the exception at the specified
  40.     priority (-127 to 127).  specified vector is called in a C
  41.     compatible way with one user argument (arg).  Specifying a
  42.     priority of -128 does not make sense because this is the lowest
  43.     allowed priority and the Q interrupt will thus never occur.
  44.  
  45.     If vector is null, the exception and Q interrupt is disabled.
  46.     After the last Q interrupt is removed, tc_ExceptCode is restored
  47.     to its original value.
  48.  
  49. BUGS:
  50.     The only bug that I know of is a problem with EXEC.
  51.  
  52.     What is Good:    An exception will not occur while one is Forbid()n
  53.     What is Bad:    If an exception comes in while Forbid()n, it will
  54.             NOT be immediately entered when you Permit().
  55.  
  56.     Whoops.  The exception *will* occur when EXEC next checks its
  57.     signals and exceptions, which occurs on the obvious EXEC library
  58.     calls (SetExcept(), SetSignal(), etc...)  and perhaps Wait().
  59.  
  60.     In most cases you can ignore the problem.
  61.  
  62. GENERAL WORKINGS OF Q INTERRUPTS:
  63.  
  64.     If you know how EXEC signals and the 68000 interrupt structure
  65.     works, then you know how Q interrupts work.  Simply replace
  66.     "processor" with "task" and "0-7" with "-128 to 127" for task
  67.     Q interrupt priorities (this is different from the Task's
  68.     scheduler priority).
  69.  
  70.     Q interrupts work just like 68000 interrupts.  If the task is
  71.     currently running at a Q interrupt priority N, only Q interrupts
  72.     of HIGHER priority can occur.  Q interrupts of LOWER OR EQUAL
  73.     priority are queued and will occur as soon as the priority is
  74.     lowered.  Everything occurs in priority order, the highest priority
  75.     pending interrupt is always the one running (or the task's main
  76.     routine if it has the highest priority).
  77.  
  78.     Thus, while a Q interrupt handler is running at some specific
  79.     priority, other Q interrupts at the same priority will wait
  80.     until the first one finishes and then execute in a FIFO fashion.
  81.  
  82. THE INTERRUPT VECTOR ROUTINE:
  83.  
  84.     A specific Q interrupt vector is a C subroutine called with one
  85.     longword argument (that specified when you SetQVector()'d it).
  86.     This works fine with the small model.
  87.  
  88.     The handler runs with all normal EXEC processing enabled, and in
  89.     the context of its task.  It can be viewed almost as a subroutine
  90.     call from the task.  However, you must be careful about the
  91.     reentrancy of certain functions.  STDIO, DOS, and many other
  92.     library calls are not reentrant, and you must use SetQPri() to
  93.     ensure such calls are not interrupted.    NOTE that you CAN mix
  94.     certain calls.    I don't have much info on what combinations work,
  95.     but certainly most library calls that do not depend on being
  96.     called singularly from tasks will work (for example, GetMsg()).
  97.     And, of course, if all your handler does is make some small
  98.     calculations this can interrupt anything.
  99.  
  100.     If you cause an exception (the same exception) from within the
  101.     handler, it will be remembered.  (That is, the signal is cleared
  102.     before the handler is called), and occur after your handler
  103.     returns.
  104.  
  105. USES FOR Q INTERRUPTS:
  106.  
  107.     Use #1:     To be able to execute menu options which do not effect
  108.             the 'current' operation.  E.G. if you are doing a
  109.             ray tracing you could make the intuition window's
  110.             signal bit a Q interrupt and handle Intuition messages
  111.             that way....   The main loop generating the ray
  112.             tracing would not have to continuously check for
  113.             Intuition messages.
  114.  
  115.     Use #2:     Lets say you are writing a terminal program and want
  116.             to display data comming in smoothly while sending a
  117.             file.  While this can be done easily with the
  118.             asynchronous ability of IO devices, it would be even
  119.             easier if you handled the receive with a Q interrupt...
  120.             that way, you could display received data (SendIO to
  121.             the console device) even if the file sender is in
  122.             the middle of a DOS call to read the next file block.
  123.  
  124.     Many more uses (I hope!).
  125.  
  126.                 -Matt
  127.  
  128.